package com.kjtpay.design_pattern.strategy;

class CashRebate extends CashSuper {
    //折扣
    private double moneyRebate = 1;

    // 类初始化的时候设置折扣率 0 ~ 1
    public CashRebate(double moneyRebate) {
        if (moneyRebate > 1) {
            this.moneyRebate = 1;
            return;
        }
        if (moneyRebate < 0) {
            this.moneyRebate = 0;
            return;
        }
        this.moneyRebate = moneyRebate;
    }

    @Override
    public double acceptCash(double money) {
        return money * this.moneyRebate;
    }
}
